export function queryControllerOrdersApi(page, pagesize, statuses, dateStart, dateEnd, filter, header, callback) {

    $.ajax({
        url: header.host + '/order/queryControllerOrders',
        type: "post",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        async: false,
        data: JSON.stringify({
            "token": header.token,
            "page": page,
            "pagesize": pagesize,
            "statuses": statuses,
            "dateStart": dateStart,
            "dateEnd": dateEnd,
            "filter": filter
        }),
        success: function(data) {
            console.log(JSON.stringify(data, null, 2))
            if (data.code == 200) {
                callback.success(data.data)
            } else {
                callback.fail(data.msg)
            }
        },
        error: function(xhr, errorType, error) {
            //   console.log("网络错误")
            callback.fail("网络错误")
        }
    });
}
export function getCarsApi(header, callback) {

    $.ajax({
        url: header.host + '/car/getCars',
        type: "post",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        async: true,
        data: JSON.stringify({
            "token": header.token,
        }),
        success: function(data) {
            console.log(JSON.stringify(data, null, 2))
            if (data.code == 200) {
                callback.success(data.data)
            } else {
                callback.fail(data.msg)
            }
        },
        error: function(xhr, errorType, error) {
            //   console.log("网络错误")
            callback.fail("网络错误")
        }
    });
}
export function getDriversApi(page, pagesize, filter, header, callback) {

    $.ajax({
        url: header.host + '/user/getDrivers',
        type: "post",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        async: true,
        data: JSON.stringify({
            "page": page,
            "pagesize": pagesize,
            "token": header.token,
            "filter": filter
        }),
        success: function(data) {
            console.log(JSON.stringify(data, null, 2))
            if (data.code == 200) {
                callback.success(data.data)
            } else {
                callback.fail(data.msg)
            }
        },
        error: function(xhr, errorType, error) {
            //   console.log("网络错误")
            callback.fail("网络错误")
        }
    });
}
export function dispatchOrderApi(orderId, maps, header, callback) {

    $.ajax({
        url: header.host + '/order/orderController',
        type: "post",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        async: true,
        data: JSON.stringify({
            "token": header.token,
            "orderId": orderId,
            "maps": maps

        }),
        success: function(data) {
            console.log(JSON.stringify(data, null, 2))
            if (data.code == 200) {
                callback.success(data.data)
            } else {
                callback.fail(data.msg)
            }
        },
        error: function(xhr, errorType, error) {
            //   console.log("网络错误")
            callback.fail("网络错误")
        }
    });
}
export function dispatchThirdCompanyApi(orderId, thirdCompanyId, header, callback) {

    $.ajax({
        url: header.host + '/order/dispatchThirdCompany',
        type: "post",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        async: true,
        data: JSON.stringify({
            "token": header.token,
            "orderId": orderId,
            "thirdCompanyId": thirdCompanyId

        }),
        success: function(data) {
            console.log(JSON.stringify(data, null, 2))
            if (data.code == 200) {
                callback.success(data.data)
            } else {
                callback.fail(data.msg)
            }
        },
        error: function(xhr, errorType, error) {
            //   console.log("网络错误")
            callback.fail("网络错误")
        }
    });
}
export function closeOrderApi(orderId, header, callback) {

    $.ajax({
        url: header.host + '/order/close',
        type: "post",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        async: true,
        data: JSON.stringify({
            "token": header.token,
            "orderId": orderId,

        }),
        success: function(data) {
            console.log(JSON.stringify(data, null, 2))
            if (data.code == 200) {
                callback.success(data.data)
            } else {
                callback.fail(data.msg)
            }
        },
        error: function(xhr, errorType, error) {
            //   console.log("网络错误")
            callback.fail("网络错误")
        }
    });
}
export function getCarAndDriverNumberStatusApi(header, callback) {

    $.ajax({
        url: header.host + '/order/getCarAndDriverNumberStatus',
        type: "post",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        async: true,
        data: JSON.stringify({
            "token": header.token,

        }),
        success: function(data) {
            console.log(JSON.stringify(data, null, 2))
            if (data.code == 200) {
                callback.success(data.data)
            } else {
                callback.fail(data.msg)
            }
        },
        error: function(xhr, errorType, error) {
            //   console.log("网络错误")
            callback.fail("网络错误")
        }
    });
}

export function getOrderDetailApi(orderId, header, callback) {
    $.ajax({
        url: header.host + '/order/getOrderDetail',
        type: "post",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        async: true,
        data: JSON.stringify({
            "token": header.token,
            "orderId": orderId
        }),
        success: function(data) {
            console.log(JSON.stringify(data, null, 2))
            if (data.code == 200) {
                callback.success(data.data)
            } else {
                callback.fail(data.msg)
            }
        },
        error: function(xhr, errorType, error) {
            //   console.log("网络错误")
            callback.fail("网络错误")
        }
    });
}
export function queryLogsApi(page, pagesize, dateStart, dateEnd, filter, header, callback) {
    $.ajax({
        url: header.host + '/order/queryLogsApi',
        type: "post",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        async: true,
        data: JSON.stringify({
            "token": header.token,
            "page": page,
            "pagesize": pagesize,
            "dateStart": dateStart,
            "dateEnd": dateEnd,
            "filter": filter
        }),
        success: function(data) {
            console.log(JSON.stringify(data, null, 2))
            if (data.code == 200) {
                callback.success(data.data)
            } else {
                callback.fail(data.msg)
            }
        },
        error: function(xhr, errorType, error) {
            //   console.log("网络错误")
            callback.fail("网络错误")
        }
    });
}